﻿using System;
using System.Collections.Generic;
using System.Text;
using UnionnetClient.Model;
using System.Windows.Forms;

namespace UnionnetClient
{
	class VpnStateWithUI : VpnState
	{
		public VpnStateWithUI(StateMachine stateMachine)
			: base(stateMachine)
		{
		}

		public void SetMainForm(MainForm mainForm)
		{
			this.mainForm = mainForm;
		}

		public override void Logout()
		{
			base.Logout();
			MessageBox.Show("当前登陆模式为VPN，当一段时间没有流量时自动注销。若想启动注销功能，请在设置中取消VPN登陆。",
				"提示 - 聚友登陆客户端", MessageBoxButtons.OK, MessageBoxIcon.Information);
		}

		public override void Exit()
		{
			base.Exit();
			Application.Exit();
		}

		protected override void OnConnectedStateChanged(bool r)
		{
			base.OnConnectedStateChanged(r);

			mainForm.NotifyIcon.ShowBalloonTip(5000, "网络状态", "网络" + (r ? "连接已恢复" : "异常断开\n请检查网络设备是否正常"), r ? ToolTipIcon.Info : ToolTipIcon.Warning);
			mainForm.NotifyIcon.Icon = r ? Properties.Resources.browser : Properties.Resources.browser_gray;
			mainForm.NotifyIcon.Text = string.Format("# 聚友登陆客户端 #\n网络状态 : {0}\n登陆模式 : VPN", r ? "已连接" : "异常断开");
		}

		private MainForm mainForm;
	}
}
